import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-11-18
 * Time: 21:32
 */
public class test_2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            int[] dp_y = new int[n];
            int[] dp_n = new int[n];
            dp_y[0] = arr[0];
            for (int i = 1; i < n; i++) {
                dp_y[i] = dp_n[i-1] + arr[i];
                dp_n[i] = Math.max(dp_y[i-1], dp_n[i-1]);
            }
            System.out.println(Math.max(dp_y[n-1], dp_n[n-1]));
        }
    }
}
